fix(otel): parameterize file exporter path; honor CLAUDE_CODE_TMPDIR#315
Open
lcatlett wants to merge 1 commit into
Open
fix(otel): parameterize file exporter path; honor CLAUDE_CODE_TMPDIR#315lcatlett wants to merge 1 commit into
lcatlett wants to merge 1 commit into
Conversation
The OTEL Collector file exporter hardcoded /tmp/claude-code-{events,metrics}.jsonl
inside the distroless container. The default uid (10001) cannot write to the
container's /tmp on macOS bind-mount setups, producing:
can't open new logfile: open /tmp/claude-code-metrics.jsonl: permission denied
Host-side chmod or symlinking does not reach the container filesystem.
Changes:
- Replace hardcoded paths in both otel-collector configs with
${env:OTEL_FILE_EXPORT_DIR} so the container target is configurable.
- docker-compose: set OTEL_FILE_EXPORT_DIR=/var/log/otel (in-container mount
point) and bind-mount ${CLAUDE_CODE_TMPDIR:-./otel-collector/data}/otel
into it. The /otel sub-namespace prevents collector output from sharing a
directory with Claude Code's per-uid runtime tmpdir (claude-<uid>/).
- Run the collector as root (user: "0:0") so writes succeed regardless of
bind-mount ownership on macOS.
- enable-telemetry.sh: set CLAUDE_CODE_TMPDIR fallback to project-local
./otel-collector/data when not already exported.
- .gitignore: ignore otel-collector/data/.
Verified: collector starts cleanly; OTLP POSTs land at
$CLAUDE_CODE_TMPDIR/otel/claude-code-metrics.jsonl with rotation working.
Contributor
|
@lcatlett is attempting to deploy a commit to the Thoughtbox Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The OTEL Collector file exporter hardcoded
/tmp/claude-code-{events,metrics}.jsonlinside the distroless container. The default uid (10001) cannot write to the container's/tmpon macOS bind-mount setups, producing:Host-side
chmodor symlinking does not reach the container filesystem, so this needs a config + compose fix rather than a host workaround.Changes
otel-collector/config.yaml,otel-collector/config-with-prometheus.yaml— Replace hardcoded/tmp/...with${env:OTEL_FILE_EXPORT_DIR}/...so the in-container target is configurable instead of baked into a checked-in file.docker-compose.yml(otel-collector service):OTEL_FILE_EXPORT_DIR=/var/log/otel(in-container mount point — fixed).${CLAUDE_CODE_TMPDIR:-./otel-collector/data}/otel:/var/log/otel. The/otelsub-namespace prevents collector output from sharing a directory with Claude Code's per-uid runtime tmpdir (claude-<uid>/).user: "0:0"so writes succeed regardless of bind-mount ownership on macOS.otel-collector/enable-telemetry.sh— DefaultCLAUDE_CODE_TMPDIRto project-local./otel-collector/datawhen not already exported..gitignore— Ignoreotel-collector/data/.Behavior
CLAUDE_CODE_TMPDIRexported in shell?~/.claude/tmp)$CLAUDE_CODE_TMPDIR/otel/claude-code-*.jsonl./otel-collector/data/otel/claude-code-*.jsonlTest plan
docker compose up -d otel-collectorstarts cleanly with no logfile errorlocalhost:4318/v1/metricsreturn200 partialSuccess: {}/otel/) keeps output isolated fromclaude-<uid>/lsofthat there is one writer and one active file (no duplicate writes)Notes
docker-composeinterpolates${CLAUDE_CODE_TMPDIR}from the shell that invokes it, not from Claude Code'ssettings.json. Users who want the override to apply automatically should export it from their shell rc, an.envfile, orenable-telemetry.sh.